﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LittleSolution
{
    public partial class frmAddProperties : Form
    {        
        public frmAddProperties()
        {
            InitializeComponent();     
        }

        private void frmAddProperties_Load(object sender, EventArgs e)
        {
            tbxPropertiesName.Focus();
        }        

        private void frmAddProperties_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode==Keys.Escape)
            {
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }
            else if (e.KeyCode==Keys.Enter)
            {
                btnOK_Click(btnOK, null);
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(tbxPropertiesName.Text) && !String.IsNullOrEmpty(tbxPropertiesValue.Text))
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("You must enter name and value of properties before accept");
            }
        }
        public String GetPropertiesName()
        {
            return tbxPropertiesName.Text;
        }        
        public String GetPropertiesValue()
        {
            return tbxPropertiesValue.Text;
        }
        public void SetValue(String name, String value)
        {
            tbxPropertiesName.Text = name;
            tbxPropertiesValue.Text = value;
        }
    }
}
